package com.jsgt.greekfire.repository

import com.jsgt.greekfire.bean.*
import com.jsgt.greekfire.common.http.ResponseData
import com.jsgt.greekfire.common.http.RetrofitManager
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext

class CoinCurrencyRepository : BaseRepository() {
    companion object {
        val instance = CoinCurrencyRepository()
    }

    /**
     * 获取币种列表
     */
    suspend fun getCoinList(): ResponseData<List<CoinListBean>> =
        withContext(Dispatchers.IO) {
            RetrofitManager.coinCurrencyService.getMyCoinList()
        }
    /**
     * 获取GFC币种列表数据
     */
    suspend fun getotcAd(params: Map<String, Any>): ResponseData<OtcAdBean> =
        withContext(Dispatchers.IO) {
            RetrofitManager.coinCurrencyService.otcAd(parseBody(params))
        }
    /**
     * 点击item出售  判断是否可以购买
     */
    suspend fun getotcAdState(params: Map<String, Any>): ResponseData<Any> =
        withContext(Dispatchers.IO) {
            RetrofitManager.coinCurrencyService.otcAdState(parseBody(params))
        }
    /**
     * 出售
     */
    suspend fun getAddOrder(params: Map<String, Any>): ResponseData<Any> =
        withContext(Dispatchers.IO) {
            RetrofitManager.coinCurrencyService.addOrder(parseBody(params))
        }
    /**
     * 我的订单列表
     */
    suspend fun getUserOrder(params: Map<String, Any>): ResponseData<MyOrderBean> =
        withContext(Dispatchers.IO) {
            RetrofitManager.coinCurrencyService.userOrder(parseBody(params))
        }

    /**
     * 发布广告列表
     */
    suspend fun getUserAd(params: Map<String, Any>): ResponseData<MyUserAdBean> =
        withContext(Dispatchers.IO) {
            RetrofitManager.coinCurrencyService.userAd(parseBody(params))
        }

    /**
     * 发布广告
     */
    suspend fun getAddAd(params: Map<String, Any>): ResponseData<Any> =
        withContext(Dispatchers.IO) {
            RetrofitManager.coinCurrencyService.addAd(parseBody(params))
        }

    /**
     * 撤单
     */
    suspend fun getAdDown(params: Map<String, Any>): ResponseData<Any> =
        withContext(Dispatchers.IO) {
            RetrofitManager.coinCurrencyService.adDown(parseBody(params))
        }



}